package com.qfmy.web.app.service.impl.novel;

import com.qfmy.model.entity.novel.Chapter;
import com.qfmy.web.app.mapper.novel.ChapterMapper;
import com.qfmy.web.app.service.novel.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.service.impl.novel
 * @date 2025/10/31
 * @description 小说章节
 */
@Service
public class ChapterServiceImpl implements ChapterService {

    /**
     * 注入mapper
     */
    @Autowired
    private ChapterMapper chapterMapper;

    /**
     * 根据小说ID获取章节
     *
     * @param novelId
     * @return
     */
    @Override
    public List<Chapter> getChaptersByNovelId(Integer novelId) {
        // 2. 查询数据库
        return chapterMapper.getChaptersByNovelId(novelId);
    }

    /**
     *
     *  根据小说id获取章节详情
     * @param novelId
     * @return
     */
    @Override
    public List<Chapter> getChapterDetail(Integer novelId) {
        //获取章节列表
        return chapterMapper.getChapterDetailsByNovelId(novelId);
    }

    /**
     * 根据章节索引获取章节详情
     * @param novelId
     * @param chapterIndex
     * @return
     */
    @Override
    public Chapter getChapterDetailByIndex(Integer novelId, Integer chapterIndex) {
        return chapterMapper.getChapterDetails(novelId,chapterIndex);
    }



}
